﻿package mortal.game.view.guild.cellrender
{
    import Message.Public.*;
    import com.mui.display.*;
    import flash.events.*;
    import mortal.component.gconst.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.utils.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.item.*;
    import mortal.game.view.common.menu.*;

    public class GuildItemCellRenderer extends GuildCellRenderer
    {
        private var _isNotMeet:Boolean;
        private var _notMeetCareerEffect:ScaleBitmap;
        private var _item:BaseItem;

        public function GuildItemCellRenderer()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            this._item = UIFactory.getUICompoment(BaseItem, 0, 0, this);
            this._item.setItemStyle(ItemStyleConst.Small, ImagesConst.PackItemBg, 2, 3);
            this._item.isDragAble = true;
            this.configEventListener(MouseEvent.CLICK, this.onMouseClick);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            ItemMenuRegister.unRegister(this._item);
            if (this._notMeetCareerEffect)
            {
                this._notMeetCareerEffect.dispose(param1);
                this._notMeetCareerEffect = null;
            }
            super.disposeImpl(param1);
            return;
        }// end function

        private function onMouseClick(event:MouseEvent) : void
        {
            if (this.data == null)
            {
                return;
            }
            return;
        }// end function

        public function set isNotMeetCarrer(param1:Boolean) : void
        {
            this._isNotMeet = param1;
            if (this._isNotMeet)
            {
                if (!this._notMeetCareerEffect)
                {
                    this._notMeetCareerEffect = ResourceConst.getScaleBitmap(ImagesConst.PackDisable);
                    this.addChild(this._notMeetCareerEffect);
                    this._notMeetCareerEffect.width = 36;
                    this._notMeetCareerEffect.height = 36;
                    this._notMeetCareerEffect.x = 3;
                    this._notMeetCareerEffect.y = 2;
                }
            }
            if (this._notMeetCareerEffect)
            {
                this._notMeetCareerEffect.visible = this._isNotMeet;
                if (this._isNotMeet)
                {
                    this.addChild(this._notMeetCareerEffect);
                }
            }
            return;
        }// end function

        override public function get data() : Object
        {
            return super.data;
        }// end function

        override public function set data(param1:Object) : void
        {
            var _loc_2:ItemData = null;
            super.data = param1;
            this.isNotMeetCarrer = false;
            ItemMenuRegister.unRegister(this._item);
            if (param1 == null)
            {
                this._item.itemData = null;
                return;
            }
            if (param1 is ItemData)
            {
                _loc_2 = param1 as ItemData;
            }
            else if (param1 is ItemInfo)
            {
                _loc_2 = new ItemData(param1.code);
            }
            else if (param1 is SPlayerItem)
            {
                _loc_2 = new ItemData(param1 as SPlayerItem);
            }
            else
            {
                _loc_2 = null;
            }
            this._item.itemData = _loc_2;
            if (this._item.itemData)
            {
                this.isNotMeetCarrer = !ItemsUtil.isFitCarrer(_loc_2);
                ItemMenuRegister.register(this._item, this._item.itemData, ItemMenuConst.getEnabeldAttri(ItemMenuConst.GuildWareHouseItem, this._item.itemData));
            }
            return;
        }// end function

    }
}
